#ifndef __PTGUI_FILERW_H__
#define __PTGUI_FILERW_H__

#include <ptgui/ptgui.h>

#define PTGUI_FILE_SEEK_SET	0
#define PTGUI_FILE_SEEK_CUR	1
#define PTGUI_FILE_SEEK_END	2

struct ptgui_filerw
{
	int (*seek) (struct ptgui_filerw *context, rt_off_t offset, int whence);
	int (*read) (struct ptgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
	int (*write)(struct ptgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
	int (*tell) (struct ptgui_filerw *context);
	int (*eof)	(struct ptgui_filerw *context);
	int (*close)(struct ptgui_filerw *context);
};
typedef struct ptgui_filerw ptgui_filerw_t;

struct ptgui_filerw *ptgui_filerw_create_file(const rt_char_t *filename, const rt_char_t *mode);
struct ptgui_filerw *ptgui_filerw_create_mem(const rt_uint8_t *mem, rt_size_t size);

int ptgui_filerw_seek(struct ptgui_filerw *context, rt_off_t offset, int whence);
int ptgui_filerw_read(struct ptgui_filerw *context, void *buffer, rt_size_t size, rt_size_t count);
int ptgui_filerw_write(struct ptgui_filerw *context, const void *buffer, rt_size_t size, rt_size_t count);
int ptgui_filerw_tell(struct ptgui_filerw *context);
int ptgui_filerw_eof(struct ptgui_filerw *context);
int ptgui_filerw_close(struct ptgui_filerw *context);

/* get memory data from filerw memory object */
const rt_uint8_t *ptgui_filerw_mem_getdata(struct ptgui_filerw *context);

#endif
